<template>
  <div class="app-container">
    <el-dialog :title="title" :visible.sync="visible" width="900px" v-if="visible" append-to-body
      :close-on-click-modal="false">
      <el-table v-loading="loading" :data="tableList" stripe border>
        <el-table-column label="序号" align="center" type="index" width="64px" />
        <el-table-column label="权益名称" align="center" prop="name" />
        <el-table-column label="权益领取时间" align="center" width="200px">
          <template slot-scope="scope">
            <span>{{scope.row.startTime}} - {{scope.row.endTime}}</span>
          </template>
        </el-table-column>
        <el-table-column label="配置时间" align="center" prop="updateTime" width="200px" :show-overflow-tooltip="true" />
        <el-table-column label="权益激活数量" align="center" prop="amount" :show-overflow-tooltip="true" />
        <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="handleView(scope.row)">查看明细</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList"></pagination>
      <!-- 明细 -->
      <el-dialog width="800px" :title="innerTitle" :visible.sync="innerVisible" append-to-body>
        <div class="listBox">
          <div class="listBox_head">
            <el-form :model="queryParamsTwo" ref="queryForm" :inline="true">
              <el-form-item label="" prop="">
                <el-input v-model="queryParamsTwo.keyword" placeholder="姓名/手机号/哈希码" clearable />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>
          </div>
          <p style="margin-bottom:20px">
            <export-excel-button title="历史权益明细" action="/equityManager/equityCard/inventory/issue/detail/export" :params="ExportParams" />
          </p>
          <el-table v-loading="loading2" :data="tableListTwo" stripe border>
            <el-table-column label="序号" align="center" type="index" width="64px" />
            <el-table-column label="姓名" align="center" prop="name" :show-overflow-tooltip="true" />
            <el-table-column label="手机号" align="center" prop="phone" :show-overflow-tooltip="true" />
            <el-table-column label="激活时间" align="center" prop="createTime" :show-overflow-tooltip="true" />
            <el-table-column label="哈希码" align="center" prop="code" :show-overflow-tooltip="true" />
          </el-table>
          <pagination v-show="total2>0" :total="total2" :page.sync="queryParamsTwo.pageNum"
            :limit.sync="queryParamsTwo.pageSize" @pagination="getIssueDetailLs"></pagination>
        </div>
      </el-dialog>
    </el-dialog>
  </div>
</template>

<script>
  import {
    inventoryIssueLs,
    inventoryIssueDetailLs
  } from "@/api/equityManager/equityCard";
  import ExportExcelButton from "@/components/ExportExcelButton/index";
  export default {
    // dicts: ['asset_card_type'],
    name: "Dialog",
    data() {
      return {
        labelWidth: '120px',
        inputWidth: '300px',
        id: '', //
        innerVisible: false,
        innerTitle: '',
        // 是否禁用表单
        disabled: false,
        // 弹出层标题
        title: "历史配置权益",
        // 是否显示弹出层
        visible: false,
        loading: false,
        loading2: false,
        // 总条数
        total: 0,
        // 数字权益卡列表表格数据
        tableList: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          equityCardId:'',
        },
        tableListTwo:[],
        total2: 0,
        queryParamsTwo: {
          pageNum: 1,
          pageSize: 10,
          equityId: '',//权益配置id
          keyword:'',//查询关键字
        }
      };
    },
    components: {
      ExportExcelButton
    },
    computed: {
      ExportParams() {
        const params = {
          ...this.queryParamsTwo,
        };
        return params;
      },
    },
    created() {

    },
    methods: {
      /** 打开发行管理弹框 */
      open(id) {
        this.queryParams.equityCardId = id
        // this.reset();
        this.getList()
        this.visible = true
      },
      // 取消按钮
      cancel() {
        this.visible = false;
        // this.reset();
      },
      // 历史配置权益列表
      getList() {
        this.loading = true;
        inventoryIssueLs(this.queryParams).then(response => {
          this.tableList = response.result.records;
          this.total = response.result.total;
          this.loading = false;
        });
      },
      // 历史配置权益明细列表
      getIssueDetailLs() {
        this.loading2 = true;
        inventoryIssueDetailLs(this.queryParamsTwo).then(response => {
          this.tableListTwo = response.result.records;
          this.total2 = response.result.total;
          this.loading2 = false;
        });
      },
      /** 查看明细 */
      handleView(row) {
        this.innerTitle = '历史权益明细' + '（' + row.name + '）'
        this.queryParamsTwo.equityId = row.id
        this.getIssueDetailLs()
        this.innerVisible = true
      },
      /** 序号 */
      // rowIndex({
      //   row,
      //   rowIndex
      // }) {
      //   row.index = rowIndex + 1;
      // },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParamsTwo.pageNum = 1;
        this.getIssueDetailLs();
      },
      /** 重置按钮操作 */
      resetQuery() {
        // this.resetForm("queryForm");
        this.reset();
        this.handleQuery();
      },
      // 表单重置
      reset() {
        this.queryParamsTwo.pageNum = 1;
        this.queryParamsTwo.keyword = '';
      },
    }
  };

</script>
<style scoped>
  .img_box {
    width: 100px;
    height: 70px;
    border-radius: 4px;
  }

</style>
